<html>
<head>
<%@ include file="../includes/comun.jsp"%>
<style>
	.deno  {font-weight: bold !important;}
	.monto {width: 100%; text-align: right;}
	.monto2 {width: 100%; text-align: right;}
	.td0101 {width: 30%; text-align: right;}
	.td0102 {width: 30%; text-align: right;}
	.td0103 {width: 40%; text-align: right;}
	.td0201 {width: 30%; text-align: right;}
	.td0202 {width: 70%; text-align: right;}
	.error  {font-weight: bold !important; color: red !important;}
	.azu    {font-weight: bold !important; color: blue !important;}
	.ver    {font-weight: bold !important; color: green !important;}
	.roj    {font-weight: bold !important; color: red !important;}
</style>
<script type="text/javascript">
var ESTADO_CAJA_CERRADA_ID = "${ESTADO_CAJA_CERRADA_ID}";
var NOMBRE_TIPO_CAJA = "${tipo}";
NOMBRE_TIPO_CAJA =NOMBRE_TIPO_CAJA.toLowerCase();
</script>
<script language="javascript" src="<%=request.getContextPath()%>/js/operatoria/CerrarCaja.js<%=aleatorio%>"></script>
</head>
<body>
<c:choose>
<c:when test="${cache.instancia.sistemaActivado}"> 
<center>
<table class="tblTitulo" style="width: 99%!important"><tr><td>Cierre de ${tipo}</td></tr></table>

<div style="width: 500px">

<form name="frm" id="frm" method="post" action="<%=request.getContextPath()%>/apertura.do?method=save">

<c:forEach items="${cache.instancia.simbolosDivisa}" var="simbolo">
<input type="hidden" id="divSim${simbolo.valoralfanumerico}" value="${simbolo.descripcion}"/>
</c:forEach>

<table class="tblFormulario">
<tr><td class="etiqueta">Tipo de Divisa:</td>
	<td class="valor">
	<select id="selDivisa" style="width: 150px" onchange="cambiarDivisa()">
		<c:forEach items="${cache.instancia.divisas}" var="divisa">
		<option value="${divisa.valoralfanumerico}">${divisa.descripcion}</option>
		</c:forEach>
	</select></td>
	<td class="etiqueta">Estado:</td>
	<td class="valor" id="estDivisa">&nbsp;</td></tr>
<tr>
<td colspan="4">
<input type="hidden" id="tipo" value="${tipo}"/>
<!-- INI: CAJAS -->
<c:forEach items="${cajas}" var="caja">
<input type="hidden" id="cajOpe${caja.divisaId}" value="${caja.operacionId}"/>
<input type="hidden" id="cajCod${caja.divisaId}" value="${caja.cajaId}"/>
<input type="hidden" id="cajEst${caja.divisaId}" value="${caja.estadoId}"/>
<input type="hidden" id="cajEdi${caja.divisaId}" value="${caja.modificacionCierreHabilitada}"/>

<c:set var="clsExisteDec" value="montoEnt"/>

<table class="tblListado" id="tblCaja${caja.divisaId}" style="display: none">
<tr>
<th>Denominaci&oacute;n</th>
<th>Cantidad</th>
<th>Monto</th>
</tr>
<!-- INI: TIPO DENOMINACION -->
<c:forEach items="${cache.instancia.tiposDenominacion}" var="tipo">
<tr class="trDen"><td colspan="3" class="deno">${tipo.descripcion}</td></tr>
<!-- INI: DENOMINACIONES -->
<c:forEach items="${caja.montosDenominacion}" var="monto">
<c:set var="clsDec" value="montoEnt"/>
<c:if test="${monto.valorNumerico < 1}">
	<c:set var="clsDec" value="montoDec"/>
	<c:set var="clsExisteDec" value="montoDec"/>
</c:if>
<c:if test="${monto.tipoId == tipo.codigoparametro}">
<tr id="trABC">
<td class="td0101 noeditable">
<input type="hidden" name="i${monto.secuenciaId}" value="${monto.secuenciaId}" class="i${monto.divisaId}">
<input type="hidden" name="n${monto.secuenciaId}" value="${monto.valorNumerico}" class="n${monto.divisaId}">
<input type="hidden" name="t${monto.secuenciaId}" value="${monto.tipoId}" class="t${monto.divisaId}">
${monto.valorTextoHTML}
<label id="numero_m${monto.secuenciaId}" style="display: none;">${monto.valorNumerico}</label></td>
<td class="td0102 noeditable" id="unidad_m${monto.secuenciaId}"></td>
<td class="td0103">
<input type="text" name="m${monto.secuenciaId}" class="monto m${monto.divisaId} ${clsDec}" <c:if test="${clsDec == 'montoDec'}">onblur="formatearNumeroFormulario(this)" onkeypress="return fieldNumber(event,this)"</c:if> value="${monto.valorIngresadoMascara}"/>
</td>
</tr>
</c:if>
</c:forEach>
<!-- FIN: DENOMINACIONES -->
</c:forEach>
<!-- FIN: TIPO DENOMINACION -->
<tr><td colspan="3">&nbsp;</td></tr>
<tr><td class="td0201 noeditable">Deteriorados            </td><td colspan="2" class="td0202"><input type="text" name="monDet${caja.divisaId}" id="monDet${caja.divisaId}" class="monto m${caja.divisaId} ${clsExisteDec}" <c:choose><c:when test="${clsExisteDec == 'montoDec'}">onblur="formatearNumeroFormulario(this)" onkeypress="return fieldNumber(event,this)" value="<fmt:formatNumber value="${caja.montoDeteriorados}" pattern="###########0.00"/>"</c:when><c:otherwise>value="<fmt:formatNumber value="${caja.montoDeteriorados}" pattern="############"/>"</c:otherwise></c:choose>></td></tr>
<tr><td class="td0201 noeditable">Patr&oacute;n de Calidad</td><td colspan="2" class="td0202"><input type="text" name="patCal${caja.divisaId}" id="patCal${caja.divisaId}" class="monto m${caja.divisaId} ${clsExisteDec}" <c:choose><c:when test="${clsExisteDec == 'montoDec'}">onblur="formatearNumeroFormulario(this)" onkeypress="return fieldNumber(event,this)" value="<fmt:formatNumber value="${caja.patronCalidad}" pattern="###########0.00"/>"</c:when><c:otherwise>value="<fmt:formatNumber value="${caja.patronCalidad}" pattern="############"/>"</c:otherwise></c:choose>></td></tr>
<tr><td class="td0201 noeditable azu">Monto Total             </td><td colspan="2" class="td0202"><input type="text" name="monTot${caja.divisaId}" id="monTot${caja.divisaId}" class="monto noeditable azu" value="<fmt:formatNumber value="${caja.montoTotal}" pattern="##########.00"/>" readonly/></td></tr>
<tr><td class="td0201 noeditable ver">Monto Total Sistema     </td><td colspan="2" class="td0202"><input type="text" name="monSis${caja.divisaId}" id="monSis${caja.divisaId}" class="monto2 noeditable ver" value="${caja.montoTotalSistemaMascara}" readonly/></td></tr>
<tr><td class="td0201 noeditable roj">Monto Total Descuadre   </td><td colspan="2" class="td0202"><input type="text" name="monDes${caja.divisaId}" id="monDes${caja.divisaId}" class="monto noeditable roj" value="" readonly/></td></tr>
</table>
</c:forEach>
<!-- FIN: CAJAS -->
</td></tr> 
<tr><td colspan="4" style="text-align: center;">
	<input type="button" class="boton1" value="Cancelar" id="btnCancelar"/> &nbsp; &nbsp;
	<input type="button" class="boton1" value="Cerrar ${tipo}" id="btnCerrar"/> &nbsp; &nbsp;
	<input type="button" class="boton1" value="Reimprimir Voucher" id="btnImprimir"/>
	<!-- input type="button" class="boton1" value="Autorizar Cierre" id="btnAutorizar"/ -->
	</td></tr>
</table>
<%@ include file="../includes/impresionVoucher.jsp"%>
</form>
<table id="tblEstadoCaja" style="display: none;">
<c:forEach items="${cache.instancia.estadosCaja}" var="estado">
<tr><td>${estado.codigoparametro}</td><td>${estado.descripcion}</td></tr>
</c:forEach>
</table>
</div>
</center>
<%request.setAttribute("significativaVisible","false");%>
<%@ include file="../includes/ConfirmacionOperacion.jsp"%>
</c:when>
<c:otherwise>
<jsp:include page="../includes/mensajeInactivo.jsp"></jsp:include>
</c:otherwise>
</c:choose>
</body>
</html>